<?php
 // START GET DATA THEO GET  METHOD-------------
	if(!isset($_GET['page']) || $_GET['page'] == null){echo 'hể'; $_GET['page'] = 1;}	

	$order=" id desc";
	$url="index.php?page=";
	if(isset($_GET['ext'])){
		
		switch($_GET['ext']){
			case 'views':
			case 'likes':
			case 'comments':
			$order= $_GET['ext']." ".$_GET['sort'];
			break;
			case "date":
			$order= "id ".$_GET['sort'];
			/*
			case 'picture': $where=' where is_image=1';break;
			case 'video': $where=' where is_video=1';break;
			case 'text': $where=' where is_text=1';break;
			*/
		}
	$url="index.php?ext=".$_GET['ext']."&sort=".$_GET['sort']."&page=";
	}
	
	
	$cache=new Cache;
	$sql ="select id,cat_id,post_id,username,id_album ,is_image,is_video,is_text from index_post ".$where." order by ".$order;
	$sql2="select id from index_post ".$where;

	$pager = new Pagination($sql,4,4,$url,5,"post");
	$pager->setDebug(false);
	$data[info] = $pager->paginate($cache,$sql2);
	$data[nav]	= $pager->renderFullNav();
	$data['page']=$pager->get_num_page();
	
	// END OF GET DATA THEO GET MOTHOD

	if($data['page']<$_GET['page']){
		$data[info]='';
	}
	

	// NEU GET PAGE = 1 HOAC GET PAGE % 5 ==0 , THI RENDER LAI DATA
	if(!isset($_GET['page']) || $_GET['page']==1 || $_GET['page']% LOAD_TIME ==0){
			
			
			
			$data1[title]=web_title(HEAD,'home');

			loadview('template/header',$data1);
			loadview("news/list_news",$data);
		//loadview('template/right');
	}else{
		exit();
	}